package org.apache.hadoop.hdfs.server.datanode;

import java.util.concurrent.BlockingQueue;

public class ChunkQueueSink extends Thread {
	
	private BlockingQueue<Chunk> chunkQueue;
	private boolean running = true;
	
	public ChunkQueueSink(BlockingQueue<Chunk> chunkQueue) {
		this.chunkQueue = chunkQueue;
	}
	
	public void run() {
		
		System.out.println("Sink starting");
		
		while (running) {
			try {
				chunkQueue.take();
				System.out.println("Sink taken chunk off queue");
			}
			catch (InterruptedException ex) {
				System.out.println("Interrupted");
			}
		}
		
		System.out.println("Sink ending");
		
	}
	
	public void stopRunning() {
		
		this.running = false;
		this.interrupt();
	}
}